//
//  DSXInputView.m
//  XiangBaLao
//
//  Created by Apple on 15/12/23.
//  Copyright © 2015年 Apple. All rights reserved.
//

#import "DSXInputView.h"

@implementation DSXInputView
@synthesize imageView = _imageView;
@synthesize textField = _textField;
@synthesize image = _image;
@synthesize placeHolder = _placeHolder;

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.layer.cornerRadius = 5.0;
        self.layer.masksToBounds = YES;
        self.backgroundColor = [UIColor whiteColor];
        self.layer.borderWidth = 1;
        self.layer.borderColor = [UIColor colorWithRed:0.81 green:0.80 blue:0.81 alpha:1.00].CGColor;
        
        //图标
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 20, 20)];
        [self addSubview:_imageView];
        //分割线
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(40, 10, 1, 20)];
        line.backgroundColor = [UIColor colorWithRed:0.73 green:0.76 blue:0.79 alpha:1.00];
        [self addSubview:line];
        //输入控件
        _textField = [[UITextField alloc] initWithFrame:CGRectMake(50, 10, frame.size.width-60, 20)];
        _textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        _textField.returnKeyType = UIReturnKeyDone;
        _textField.font = [UIFont systemFontOfSize:16.0];
        [self addSubview:_textField];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image placeHolder:(NSString *)placeHolder{
    if (self = [self initWithFrame:frame]) {
        self.image = image;
        self.placeHolder = placeHolder;
    }
    return self;
}

- (void)setImage:(UIImage *)image{
    _image = image;
    _imageView.image = image;
}

- (void)setPlaceHolder:(NSString *)placeHolder{
    _placeHolder = placeHolder;
    _textField.placeholder = _placeHolder;
}

@end
